package datastructure;

import mpi.MPI;
import mpi.Status;

public class DataStructure{
	private int[] dataInt;
	private double[] dataDouble;
	private long[] dataLong;
	
	public DataStructure(int[] dataInt_){
		dataInt = dataInt_;
	}
	
	public DataStructure(double[] dataDouble_){
		dataDouble = dataDouble_;
	}
	
	public DataStructure(long[] dataLong_){
		dataLong = dataLong_;
	}	
	
	public void BcastInt(int root){
		MPI.COMM_WORLD.Bcast((Object)dataInt, 0, dataInt.length, MPI.INT, root);
	}
	
	public void BcastDouble(int root){
		MPI.COMM_WORLD.Bcast((Object)dataDouble, 0, dataDouble.length, MPI.DOUBLE, root);
	}
	
	public void BcastLong(int root){
		MPI.COMM_WORLD.Bcast((Object)dataLong, 0, dataLong.length, MPI.LONG, root);
	}
	
	public void SendInt(int dest, int tag){
		MPI.COMM_WORLD.Send((Object)dataInt, 0, dataInt.length, MPI.INT, dest, tag);
	}
	
	public void SendLong(int dest, int tag){
		MPI.COMM_WORLD.Send((Object)dataLong, 0, dataLong.length, MPI.LONG, dest, tag);
	}
	
	public Status ReceiveLong(int source, int tag){
		Status status;
		return status = MPI.COMM_WORLD.Recv((Object)dataLong, 0, dataLong.length, MPI.LONG, source, tag);
	}
	
	public Status ReceiveInt(int source, int tag){
		Status status;
		return status = MPI.COMM_WORLD.Recv((Object)dataInt, 0, dataInt.length, MPI.INT, source, tag);
	}
	
	public void updateDataInt(int[] dataInt_){
		dataInt = dataInt_;
	}
	
	public void updateDataDouble(double[] dataDouble_){
		dataDouble = dataDouble_;
	}
	
	public void updateDataLong(long[] dataLong_){
		dataLong = dataLong_;
	}
	
}
